package leetcode.字符串;

import java.util.Set;

public class 反转字符串中的元音首字母345 {
    public String reverseVowels(String s) {
        if(s.length() <= 1) return s;
        String yuanyin = "aeiouAEIOU";
        int l = 0, r = s.length() - 1;
        char[] arr = new char[s.length()];
        while(l <= r){
            boolean jL = (yuanyin.indexOf(s.charAt(l)) != -1);
            boolean jR = (yuanyin.indexOf(s.charAt(r)) != -1);
            if(!jL) arr[l] = s.charAt(l++);
            if(!jR) arr[r] = s.charAt(r--);
            if(jL && jR){
                arr[l] = s.charAt(r);
                arr[r] = s.charAt(l);
                l++;
                r--;
            }
        }
        return new String(arr);

    }

    public static void main(String[] args) {
        new 反转字符串中的元音首字母345().reverseVowels("hello");
    }
}
